tests: Use the test ATContext for every test
authorEmmanuele Bassi <ebassi@gnome.org>
Fri, 9 Oct 2020 17:17:04 +0000 (18:17 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Mon, 12 Oct 2020 15:19:32 +0000 (16:19 +0100)
Otherwise we're going to need a full desktop session in order to run the
test suite.

testsuite/css/change/meson.build
testsuite/css/meson.build
testsuite/css/nodes/meson.build
testsuite/css/style/meson.build
testsuite/gdk/meson.build
testsuite/gsk/meson.build
testsuite/gtk/meson.build
testsuite/reftests/meson.build
testsuite/tools/meson.build

index 04204ed5ba660cdba60c5b883ed8f4dd21c2ac47..83e37ae2f65f0cad864ac8c375bbb9546e796763 100644 (file)
@@ -9,14 +9,13 @@ test_change = executable(
   install: get_option('install-tests'),
   install_dir: testexecdir,
 )
+
 test('change', test_change,
-     args: [ '--tap', '-k' ],
-     protocol: 'tap',
-     env: [
-            'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-            'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-          ],
-     suite: 'css')
+  args: [ '--tap', '-k' ],
+  protocol: 'tap',
+  env: csstest_env,
+  suite: 'css',
+)
 
 test_data = [
   'test1.css', 'test1.ui', 'test1.nodes',
index bac0ebd074ae6ed6461c117fda2a506a2ae9f992..931502bef7b59ad7a42e33cc5b3fef8fddbb5c59 100644 (file)
@@ -1,3 +1,12 @@
+csstest_env = environment()
+csstest_env.set('GTK_TEST_ACCESSIBLE', '1')
+csstest_env.set('GSK_RENDERER', 'cairo')
+csstest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+csstest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+csstest_env.set('GIO_USE_VFS', 'local')
+csstest_env.set('GSETTINGS_BACKEND', 'memory')
+csstest_env.set('G_ENABLE_DIAGNOSTIC', '0')
+
 subdir('parser')
 subdir('nodes')
 subdir('style')
@@ -14,10 +23,7 @@ test_api = executable('api', 'api.c',
 test('api', test_api,
      args: ['--tap', '-k' ],
      protocol: 'tap',
-     env: [
-            'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-            'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-          ],
+     env: csstest_env,
      suite: 'css')
 
 test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
@@ -29,10 +35,7 @@ test_data = executable('data', ['data.c', '../../gtk/css/gtkcssdataurl.c'],
 test('data', test_data,
      args: ['--tap', '-k' ],
      protocol: 'tap',
-     env: [
-            'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-            'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-          ],
+     env: csstest_env,
      suite: 'css')
 
 if get_option('install-tests')
@@ -46,20 +49,24 @@ endif
 
 if false and get_option ('profiler')
 
+  adwaita_env = csstest_env
+  adwaita_env.set('GTK_THEME', 'Adwaita')
   test('performance-adwaita', test_performance,
        args: [ '--mark', 'css validation',
                '--name',  'performance-adwaita',
                '--output', join_paths(meson.current_build_dir(), 'output'),
                join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Adwaita' ],
+       env: adwaita_env,
        suite: [ 'css' ])
 
+  empty_env = csstest_env
+  empty_env.set('GTK_THEME', 'Empty')
   test('performance-empty', test_performance,
        args: [ '--mark', 'css validation',
                '--name',  'performance-empty',
                '--output', join_paths(meson.current_build_dir(), 'output'),
                join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Empty' ],
+       env: empty_env,
        suite: [ 'css' ])
 
 endif
index 720ba46db8b40f1a01853368542f6e1fca76bab1..11ed48b9e5d4ae98b00834f4bff564c1b7ae0aca 100644 (file)
@@ -7,13 +7,11 @@ test_nodes = executable('test-css-nodes', 'test-css-nodes.c',
                         install_dir: testexecdir,
                         dependencies: libgtk_dep)
 test('nodes', test_nodes,
-     args: [ '--tap', '-k' ],
-     protocol: 'tap',
-     env: [
-            'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-            'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-          ],
-     suite: 'css')
+  args: [ '--tap', '-k' ],
+  protocol: 'tap',
+  env: csstest_env,
+  suite: 'css',
+)
 
 test_data = [
   'box.ltr.nodes',
@@ -77,5 +75,4 @@ if get_option('install-tests')
                  install_dir: testdatadir)
 
   install_data(test_data, install_dir: testexecdir)
-
 endif
index cadbf8dc169536185ba86df733bed5cc1e5b52bb..b54adf7c688d4d14e6d2dd1085a42da0347a7485 100644 (file)
@@ -17,13 +17,11 @@ test_style = executable(
   install_dir: testexecdir,
 )
 test('style', test_style,
-     args: [ '--tap', '-k' ],
-     protocol: 'tap',
-     env: [
-            'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-            'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-          ],
-     suite: 'css')
+  args: [ '--tap', '-k' ],
+  protocol: 'tap',
+  env: csstest_env,
+  suite: 'css',
+)
 
 test_data = [
   'adjacent-states.css',
@@ -65,5 +63,4 @@ if get_option('install-tests')
                  install_dir: testdatadir)
 
   install_data(test_data, install_dir: testexecdir)
-
 endif
index bd7744ee0e53c7fee71e0264ea898694ebf0fc40..aa93f8384d74845e6fd7e007f174f2b2039aebf4 100644 (file)
@@ -16,28 +16,31 @@ tests = [
 
 foreach t : tests
   test_exe = executable(t, '@0@.c'.format(t),
-                        c_args: common_cflags,
-                        dependencies: libgtk_dep,
-                        install: get_option('install-tests'),
-                        install_dir: testexecdir)
+    c_args: common_cflags,
+    dependencies: libgtk_dep,
+    install: get_option('install-tests'),
+    install_dir: testexecdir,
+  )
 
   test(t, test_exe,
-       args: [ '--tap', '-k' ],
-       protocol: 'tap',
-       env: [
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-            ],
-       suite: 'gdk')
+    args: [ '--tap', '-k' ],
+    protocol: 'tap',
+    env: [
+      'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
+      'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+    ],
+    suite: 'gdk',
+  )
 
   if get_option('install-tests')
     test_cdata = configuration_data()
     test_cdata.set('testexecdir', testexecdir)
     test_cdata.set('test', t)
     configure_file(input: 'gdk.test.in',
-                   output: '@0@.test'.format(t),
-                   configuration: test_cdata,
-                   install: true,
-                   install_dir: testdatadir)
+      output: '@0@.test'.format(t),
+      configuration: test_cdata,
+      install: true,
+      install_dir: testdatadir,
+    )
   endif
 endforeach
index d9cb63f1ecac62a4231bd945233c3e6e123b7427..07b2d05955f4e85a71211532295b8d5abfea8524 100644 (file)
@@ -101,6 +101,7 @@ foreach renderer : renderers
                   join_paths(meson.current_source_dir(), 'compare', test + '.png')],
            env: [
                   'GSK_RENDERER=' + renderer[0],
+                  'GTK_TEST_ACCESSIBLE=1',
                   'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
                   'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
                 ],
@@ -178,6 +179,7 @@ foreach test : node_parser_tests
                ],
          env: [
                 'GSK_RENDERER=opengl',
+                'GTK_TEST_ACCESSIBLE=1',
                 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
                 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
               ],
@@ -211,6 +213,7 @@ foreach t : tests
        protocol: 'tap',
        env: [
               'GSK_RENDERER=cairo',
+              'GTK_TEST_ACCESSIBLE=1',
               'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
               'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
             ],
index 11509fa5bca580c4647e4dacb5fc76a87605d999..6b973c1d9bf3b08703ee06224ee5a08f1f7516cd 100644 (file)
@@ -146,6 +146,15 @@ is_debug = get_option('buildtype').startswith('debug')
 
 test_cargs = []
 
+test_env = environment()
+test_env.set('GTK_TEST_ACCESSIBLE', '1')
+test_env.set('GSK_RENDERER', 'cairo')
+test_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+test_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+test_env.set('GIO_USE_VFS', 'local')
+test_env.set('GSETTINGS_BACKEND', 'memory')
+test_env.set('G_ENABLE_DIAGNOSTIC', '0')
+
 if os_unix
   # tests += [['defaultvalue']]  # disabled in Makefile.am as well
   test_cargs += ['-DHAVE_UNIX_PRINT_WIDGETS']
@@ -182,11 +191,7 @@ foreach t : tests
        args: [ '--tap', '-k' ],
        protocol: 'tap',
        timeout: test_timeout,
-       env: [
-              'GSK_RENDERER=cairo',
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
-            ],
+       env: test_env,
        suite: ['gtk'] + test_extra_suites,
        should_fail: expect_fail,
   )
@@ -203,10 +208,7 @@ if add_languages('cpp', required: false)
   test('c++ keywords', test_exe,
        args: [ '--tap', '-k' ],
        #protocol: 'tap',
-       env: [
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
-            ],
+       env: test_env,
        suite: 'gtk')
   if get_option('install-tests')
     conf = configuration_data()
@@ -254,10 +256,7 @@ foreach test : focus_chain_tests
   test(test[0] + ' ' + test[1], focus_chain,
        args: [ join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.ui'),
                join_paths(meson.current_source_dir(), 'focus-chain', test[0] + '.' + test[1]) ],
-       env: [
-              'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-              'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir())
-             ],
+       env: test_env,
        suite: [ 'gtk', 'focus' ])
 endforeach
 
@@ -282,14 +281,17 @@ endif
 
 if false and get_option ('profiler')
 
+  performance_env = test_env
+  performance_env.set('GTK_THEME', 'Empty')
+
   test('performance-layout', test_performance,
        args: [ '--mark', 'size allocation', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Empty' ],
+       env: performance_env,
        suite: [ 'gtk' ])
 
   test('performance-snapshot', test_performance,
        args: [ '--mark', 'widget snapshot', join_paths(meson.current_build_dir(), '../../demos/widget-factory/gtk4-widget-factory') ],
-       env: [ 'GTK_THEME=Empty' ],
+       env: performance_end,
        suite: [ 'gtk' ])
 
 endif
index 0e8bdbc16e36d62c3c51f16a5ecdcf66856ca67c..da1edd67c82628c1a65ff446728322b3bf59c1be 100644 (file)
@@ -450,6 +450,16 @@ xfails = [
   'label-sizing.ui',
 ]
 
+reftest_env = environment()
+reftest_env.set('GTK_TEST_ACCESSIBLE', '1')
+reftest_env.set('GSK_RENDERER', 'opengl')
+reftest_env.set('G_TEST_SRCDIR', meson.current_source_dir())
+reftest_env.set('G_TEST_BUILDDIR', meson.current_build_dir())
+reftest_env.set('GIO_USE_VFS', 'local')
+reftest_env.set('GSETTINGS_BACKEND', 'memory')
+reftest_env.set('G_ENABLE_DIAGNOSTIC', '0')
+reftest_env.set('REFTEST_MODULE_DIR', meson.current_build_dir())
+
 foreach testname : testdata
   if testname.endswith('.ui') and not testname.endswith('.ref.ui')
     test('reftest ' + testname, gtk_reftest,
@@ -459,12 +469,7 @@ foreach testname : testdata
                  join_paths(meson.current_source_dir(), testname),
          ],
          protocol: 'tap',
-         env: [
-                'GSK_RENDERER=opengl',
-                'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
-                'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
-                'REFTEST_MODULE_DIR=@0@'.format(meson.current_build_dir())
-              ],
+         env: reftest_env,
          suite: 'reftest',
          should_fail: xfails.contains(testname))
   endif
index 85fc54aac4694dbcd00234168dcc539994253ebc..1369ccfedcaea830c4ddbdfa3fd38ce253c9cd7a 100644 (file)
@@ -23,6 +23,7 @@ if bash.found()
          env: [
                 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
                 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
+                'GTK_TEST_ACCESSIBLE=1',
                 'GTK_BUILDER_TOOL=@0@'.format(get_variable('gtk4_builder_tool').full_path()),
                 'GTK_QUERY_SETTINGS=@0@'.format(get_variable('gtk4_query_settings').full_path())
               ],